#!/bin/sh
echo this is phoenix option scrpits
[ "x$1" == "x" ] && echo you need to input customer,exit && exit 1
customer_tmp=$1
customer=`echo $customer_tmp |awk -F ":" '{print $1}'`
file_option=$2
input_option=$3
input_action=$4
echo customer=$customer and interface file option=$file_option
error_string="错误:检查到最后一个字符是逗号，可能是option/action之间有空格造成的，也可能是书写有误，请先检查输入是否正确"
echo input_option=$input_option
[ "`echo ${input_option:0-1}`" == "," ] && echo $error_string && exit 1
echo input_action=$input_action
[ "`echo ${input_action:0-1}`" == "," ] && echo $error_string  && exit 1
if [ "$file_option" == "check" ];then 
    echo you want to check $customer interface
    if [ -f /usr/local/scripts/build_scripts/customer_interfaces/"$customer" ];then
        echo $customer interface option as follow:
        cat /usr/local/scripts/build_scripts/customer_interfaces/"$customer"
        exit 0
    else
        if [ "$customer" == "all" ]; then
            echo all customers as follow：
            for tmp_name in `ls /usr/local/scripts/build_scripts/customer_interfaces/`
                do
                    sed -n 1p /usr/local/scripts/build_scripts/customer_interfaces/$tmp_name
                done
            exit 0
        else
            echo $customer interface option file is not exist, you can add it via set interface_file=config
            exit 0
        fi
    fi
else
    echo you want to add or modify $customer interface
fi
echo "#$customer_tmp" >/usr/local/scripts/build_scripts/customer_interfaces/"$customer"
[ "x$input_option" != "x" ] && echo build_option:$input_option >> /usr/local/scripts/build_scripts/customer_interfaces/"$customer"
[ "x$input_action" != "x" ] && echo build_action:$input_action >> /usr/local/scripts/build_scripts/customer_interfaces/"$customer"
echo "$customer" interfaces as follow:
cat /usr/local/scripts/build_scripts/customer_interfaces/"$customer"

